package com.gufe.controller.admin.index;

import com.gufe.dto.adminIndex.IndexLineChartDTO;
import com.gufe.result.Result;
import com.gufe.service.admin.index.IndexService;
import com.gufe.vo.adminIndex.IndexBarChartVO;
import com.gufe.vo.adminIndex.IndexDateVO;
import com.gufe.vo.adminIndex.IndexPieChartVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/admin/index")
public class IndexController {

    @Autowired
    private IndexService indexService;

    //方框区数据
    @GetMapping
    public Result<IndexDateVO> getIndexData() {
        IndexDateVO indexData = indexService.getIndexData();
        return Result.success(indexData);
    }

    //折线图数据
    @GetMapping("/lineChart")
    public Result<IndexLineChartDTO> getLineChartData(@RequestParam Integer yearRange) {
         IndexLineChartDTO indexLineChart = indexService.getLineChartData(yearRange);
        return Result.success(indexLineChart);
    }

    //饼图数据
    @GetMapping("/pieChart")
    public Result<List<IndexPieChartVO>> getPieChartData(@RequestParam String category) {
        List<IndexPieChartVO> list = indexService.getIndexPieChartData(category);
        return Result.success(list);
    }

    //条形图数据
    @GetMapping("/barChart")
    public Result<IndexBarChartVO> getBarChartData(@RequestParam String category) {
        IndexBarChartVO indexBarChartVO = indexService.getBarChartData(category);
        return Result.success(indexBarChartVO);
    }
}
